package com.huadao.pda.project.bindingProject;

import com.huadao.pda.common.ProgressDialogHandler;
import com.huadao.pda.data.bean.Project;
import com.huadao.pda.data.http.BaseResponse;
import com.huadao.pda.data.http.RockBaseObserver;
import com.huadao.pda.modle.ProjectModel;

import io.reactivex.Observable;
import io.reactivex.Observer;

public class BindingProjectPresenter extends IBindingProjectContract.IBindingProjectPresenter {

    private ProjectModel projectModel;

    public BindingProjectPresenter(IBindingProjectContract.IBindingProjectView baseView) {
        attachView(baseView);
        projectModel=new ProjectModel(baseView.getContext());
    }

    @Override
    void bindProject(String projectId,String devId) {
        Observable<Boolean> observable=projectModel.bindingProject(projectId,devId);
        projectModel.toSubscribe(observable, new RockBaseObserver<Boolean>(this,"正在绑定项目") {
            @Override
            protected void onBaseNext(Boolean isSucc) {
                if(isSucc) {
                    baseView.bindProjectSucc();
                }else {
                    baseView.bindProjectFail();
                }
            }
        });

//        baseView.bindProjectSucc();
    }

    @Override
    public void detachView() {
        super.detachView();
    }
}
